<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.hs.core.db.DBMgr"%>
 <%
String loginid = request.getParameter("loginid");
Cookie[] cookies=request.getCookies(); //读出用户硬盘上的Cookie，并将所有的Cookie放到一个cookie对象数组里面
Cookie sCookie=null; 
String svalue=null; 
String sname=null; 
String cookieName = null;
String cookiepwd = null; 
if(null != cookies){
	for(int i=0;i<cookies.length;i++){    //用一个循环语句遍历刚才建立的Cookie对象数组
	sCookie=cookies[i];   //取出数组中的一个Cookie对象 
	sname=sCookie.getName(); //取得这个Cookie的名字
	svalue=sCookie.getValue(); //取得这个Cookie的内容
	if("chdname".equals(sname)){
		cookieName =  svalue;
	} 
	if("chdpwd".equals(sname)){
		cookiepwd =  svalue;
	} 
	}
}
boolean flag = false;
if(null == cookieName){ 
    cookieName = (String)request.getAttribute("username");
}else{
	flag = true;
}
if(null!= loginid && !"".equals(loginid)){
    cookieName = loginid;
}  
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<%@ include file="include.jsp"%>  
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/highcharts216/highcharts.js"></script>
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/highcharts216/modules/exporting.js"></script>

<% 
  String info = (String)request.getAttribute("alert");
  if(null == info)
     info = "";
  String userName = (String)request.getAttribute("username");
  if(null == userName){
     if(null != cookieName){
     	userName = cookieName;
     }else{
     	userName = "";
     }
  }
  session.invalidate();
  Map data = new HashMap();
	DBMgr inst = DBMgr.getDbUtilInst(request.getSession().getServletContext());
 
	StringBuffer onesql = new StringBuffer(" select *　from (select * from (select years,count(*) as count from (select substr(YEARSTR,0,4) as years,id　from CHD_PAPERINFO where datatype=1 and YEARSTR is not null ) group by years ) order by count desc) order by years desc ");
	StringBuffer twosql = new StringBuffer(" select *　from (select * from (select years,count(*) as count from (select substr(YEARSTR,0,4) as years,id　from CHD_PAPERINFO where datatype=2 and YEARSTR is not null ) group by years ) order by count desc) order by years desc");
	String cdsql = "select * from hs_code where dicttype=3 order by ORDNUM";
	List cdlist = inst.queryList(cdsql,null);
	//StringBuffer threesql = new StringBuffer("select years,to_char(count(*)) as count from (select substr(YEARSTR,0,4) as years,id　from CHD_PAPERINFO where datatype=3 and YEARSTR is not null ) group by years");
	List list1 = inst.queryList(onesql.toString(), null);
	List list2 = inst.queryList(twosql.toString(), null); 
	//List list3 = inst.queryList(threesql.toString(), null);
   StringBuffer year1str = new StringBuffer();
   StringBuffer data1str = new StringBuffer();
   StringBuffer year2str = new StringBuffer();
   StringBuffer data2str = new StringBuffer();
   StringBuffer year3str = new StringBuffer();
   StringBuffer data3str = new StringBuffer();
   Map yearmap = new HashMap();
   Integer curryear = new Integer(TimeUtil.getCurrentYear());
  // for(int j =0;j<6;j++){
  //    int temp = (curryear - j) ;
  //     yearmap.put(temp+"",temp+"");
  // }
    int count = 1;
	for(int i =0;i<list1.size();i++){
		Map m1 = (Map)list1.get(i);
		String years = (String)m1.get("years");
		System.out.println("years:" + years);
		String countstr =  m1.get("count")+""; 
		//if(null == yearmap.get(years)){
		//	continue;
		//}
		if(count <6 ){
			if(BigNumCal.isNumeric(years)&&years.length() == 4){
				year1str.append("'").append(years).append("',");
				data1str.append(countstr).append(",");
				count++; 
			}else{
				continue;
			} 
		}else{
			break;
		}
	}
 	int count1 =1;
 	for(int j =0;j<list2.size();j++){
		Map m2 = (Map)list2.get(j);
		String years = (String)m2.get("years");
		String countstr =  m2.get("count")+"";
		//if(null == yearmap.get(years)){
		//	continue;
		//}
		if(count1 <6 ){
			if(BigNumCal.isNumeric(years)&&years.length() == 4){
				year2str.append("'").append(years).append("',");
				data2str.append(countstr).append(",");
				count1++;
			}else{
				continue;
			}
		}else{
			break;
		}
	}
	for(int k =0;k<cdlist.size();k++){
		Map m3 = (Map)cdlist.get(k);
		String cd = (String)m3.get("DICTNAME");
		//String countstr = (String)m3.get("count");
		int countall =  inst.queryCountForInt("select to_char(count(*)) as countall from CHD_PAPERINFO where datatype=3 and BOOKCD is not null and BOOKCD =?",new Object[]{cd});
		year3str.append("'").append(cd).append("',");
		data3str.append(countall).append(",");
		 
	}
	String year1strend = year1str.length()==0?"":year1str.substring(0,year1str.length()-1).toString();
	String year2strend = year2str.length()==0?"":year2str.substring(0,year2str.length()-1).toString();
	String year3strend = year3str.length()==0?"":year3str.substring(0,year3str.length()-1).toString();
	String data1strend = data1str.length()==0?"":data1str.substring(0,data1str.length()-1).toString();
	String data2strend = data2str.length()==0?"":data2str.substring(0,data2str.length()-1).toString();
	String data3strend = data3str.length()==0?"":data3str.substring(0,data3str.length()-1).toString();
%>
<script language=JavaScript>
 <!--
if(self != top) top.location.href = window.location.href;
//-->
function checkform()
{
if(isNull(document.LoginForm.UserName.value)){
  alert("请输入用户名～！");
  document.all.UserName.focus();
  return false;
}
if(isNull(document.LoginForm.Password.value)){
  alert("请输入密码～！");
  document.all.Password.focus();
  return false;
}
return true;
}
function isNull(pvalue)
 {
   var RegularExp=/^\s*$/;
   if(RegularExp.test(pvalue))
   {
     return true;
   }
   return false;
 }
function submitPage(){ 
    var LoginForm = document.forms[0];
    if(checkform()){
       LoginForm.submit();
    }
	
}
function isEntry(e){
     if(document.all)e = event;
     if(e.keyCode==13) {
             submitPage();
     };
}
function resetinput(){
    document.getElementById("UserName").value='';
        document.getElementById("Password").value='';
    
}
</script>
</head>
<body>
<div class="head" style="height:75px;">
    <img src="<%=imagePath %>logo.gif" class="logo"/>
    <div class="banner"></div>
    <div class="head_right">
    </div>
</div> 
<form name="LoginForm" action="<%=basePath %>logon.do"  method="post"> 
<table width="100%" border="0" cellspacing="0" cellpadding="0"  >
      <tr>
        
        <td class="login_parent">
            用户名<input name="UserName" id="UserName" type="text" class="name" value="<%=cookieName==null?"":cookieName %>"/><br />
            密　码<input name="Password" id="Password" type="password" class="pass" value="<%=cookiepwd==null?"":cookiepwd %>"/><br />
            <span><input name="rememberme" type="checkbox"  value="1" <%if(flag){out.println(" checked");} %>/> 记住用户名密码 </span>  
            <p><input onClick="submitPage();" type="button" class="login"/><input name="" type="button" onclick="resetinput();" class="cance"/></p>
            <span><font color=red><strong><%=info %></strong></span>
            
        </td>
       
        <td>
            <dl class="system_intro">
                <dt>系统简介</dt>
                <dd>
               <font size=2>&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp; &nbsp;&nbsp;冠心病古今文献数据库是由冠心病国家中医临床研究基地业务建设科研专项资助，主要目标为构建完善、具有可检索功能的冠心病古今文献数据库，进而提供可供院内外共享的冠心病古代与现代中医文献信息平台。</font> 
              </dd>
                <dd><font size=2> &nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp; &nbsp;&nbsp;冠心病古代文献信息库收集自先秦至民国时期有关冠心病的病名、病因病机、辨证分型、治则治法、预防调摄及经方验方和医案等的文献，建立相应数据库，进行深入挖掘研究，把握冠心病的学术发展源流。现代文献数据库则收集建国后至今关于冠心病诊治的相关权威文献，并形成与古今、中英互通的检索平台。</font>
</dd>
            </dl>
        </td>
    </tr>
</table>
 </form>
<table width="100%" border="0" cellspacing="10" cellpadding="0" class="chart">
  <tr>
    <td width="33%">
    <dl>
        <dt>现代期刊文献统计</dt>
       <dd><div id="container"   style="height:100%; margin: 0 2em; clear:both;  "></div></dd>
       </dl>
    </td>
    <td width="33%">
    <dl>
        <dt>英文文献量统计</dt>
        <dd><div id="container1"   style="height:100%; margin: 0 2em; clear:both;  "></div>
        </dd>
        </dl>
    </td>
    <td width="33%">
         <dl>
        <dt>古籍文献量统计</dt>
        
       <dd><div id="container2"   style="height:100%; margin: 0 2em; clear:both;  "></div>
       </dd>
        </dl>
    </td>
  </tr>
</table>
<div class="footer"><spring:message code="sys.copyright" /><strong><font color=red>(请使用IE浏览器)</font></div> 

</body>
</html>
<script language="javascript" type="text/javascript">


var chart;
var chart1;
var chart2;
$(document).ready(function() {
   chart = new Highcharts.Chart({
      chart: {
            renderTo: 'container',
            type: 'column' 
            
        },
        title: {
             text: ''
        },
        xAxis: {
            categories: [<%=year1strend%>],
            labels: {
                rotation: -45,
                align: 'right',
                style: {
                    font: 'normal 13px Verdana, sans-serif'
                }
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '文献数量'
            }
        },
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function() {
                return '<b>'+ this.x +'</b>年<br/>'+
                    ' 中文现代期刊文献共: '+ Highcharts.numberFormat(this.y, 0) +
                    ' 篇';
            }
        },
            series: [{
            name: '11',
            data: [<%=data1strend%>],
            color: '#d27433', 
            borderColor:  '#d27433',
            borderRadius:'5', 
            dataLabels: {
                enabled: true,
                rotation: -90,
                color: '#FFFFFF',
                align: 'right',
                x: -3,
                y: 10,
                formatter: function() {
                    return this.y;
                },
                style: {
                    font: 'normal 13px Verdana, sans-serif'
                }
            }
        }]
    });
    chart1 = new Highcharts.Chart({
      chart: {
            renderTo: 'container1',
            type: 'column' 
        },
        title: {
             text: ''
        },
        xAxis: {
            categories: [<%=year2strend%>],
            labels: {
                rotation: -45,
                align: 'right',
                style: {
                    font: 'normal 13px Verdana, sans-serif'
                }
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '文献数量'
            }
        },
        
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function() {
                return '<b>'+ this.x +'</b>年<br/>'+
                    ' 英文现代期刊文献共: '+ Highcharts.numberFormat(this.y, 0) +
                    ' 篇';
            }
        },
            series: [{
            name: '文献量',
            data: [<%=data2strend%>],
            color: '#339b9f',
            borderColor:  '#339b9f',
            borderRadius:'5', 
            dataLabels: {
                enabled: true,
                rotation: -90,
                color: '#FFFFFF',
                align: 'right',
                x: -3,
                y: 10,
                formatter: function() {
                    return this.y;
                },
                style: {
                    font: 'normal 13px Verdana, sans-serif'
                }
            }
        }]
    });
    
    chart2 = new Highcharts.Chart({
      chart: {
            renderTo: 'container2',
            type: 'column' 
        },
        title: {
             text: ''
        },
        xAxis: {
            categories: [<%=year3strend%>],
            labels: {
                rotation: -45,
                align: 'right',
                style: {
                    font: 'normal 13px Verdana, sans-serif'
                }
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '文献数量'
            }
        },
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function() {
                return '<b>'+ this.x +'</b><br/>'+
                    ' 古籍文献共: '+ Highcharts.numberFormat(this.y, 0) +
                    ' 篇';
            }
        },
            series: [{
            name: '文献量',
            data: [<%=data3strend%>],
            color: '#a39633',
            borderColor:  '#a39633',
            borderRadius:'5', 
            dataLabels: {
                enabled: true,
                rotation: -90,
                color: '#FFFFFF',
                align: 'right',
                x: -3,
                y: 10,
                formatter: function() {
                    return this.y;
                },
                style: {
                    font: 'normal 13px Verdana, sans-serif'
                }
            }
        }]
    });
   
   
});
</script>